mini.parse();

function GoodsQueryHandler() {
};

GoodsQueryHandler.instance = new GoodsQueryHandler();

//获得全局的商品数据查询表单对象
GoodsQueryHandler.goodsQueryForm = new mini.Form("goodsQueryForm");

//商品品牌默认选项
GoodsQueryHandler.bgbComboxData = {"bgbId":"-1","bgbName":"所有品牌"};
//商品供货商默认选项
GoodsQueryHandler.bgsComboxData = {"bsiId":"-1","bsiName":"所有供货商"};
//商品推荐类型所有选项
GoodsQueryHandler.goodsCommendTypeData = [
	{text: '全部', id: 0},
	{text: '精品推荐', id: 1},
	{text: '新品推荐', id: 2},
	{text: '热销推荐', id: 3},
	{text: '团购推荐', id: 4},
	{text: '所有推荐', id: 5}
];
//商品排序列所有选项
GoodsQueryHandler.goodsSortingColData = [
	{text: '默认', id: "0"},
	{text: '商品名称', id: "bgiName"},
	{text: '商品货号', id: "bgiGsn"},
	{text: '精品推荐', id: "bgiBest"},
	{text: '新品推荐', id: "bgiNew"},
	{text: '热销推荐', id: "bgiHot"},
	{text: '团购推荐', id: "bgiBuy"},
	{text: '推荐排序', id: "bgiOrder"},
	{text: '警告数量', id: "bgiWarn"},
	{text: '库存总数', id: "bgiNumber"},
	{text: '商品状态', id: "bgiState"}	
];
//商品排序方向所有选项
GoodsQueryHandler.goodsSortingDirData = [
	{text: '默认', id: "0"},
	{text: '升序排列', id: "ASC"},
	{text: '降序排列', id: "DESC"}
];


/**
 * 加载商品品牌下拉组合框
 */
GoodsQueryHandler.getBgbCombobox = function(){
	$.ajax({
        url: __root + "/getBgbCombobox.do",
        type: "POST",
        cache: false,
        dataType: 'json',
        success: function (text) {
        	var temp = [GoodsQueryHandler.bgbComboxData];
        	for(var i = 0; i < text.length; i++){
        		var item = {bgbId: text[i].bgbId, bgbName: text[i].bgbName};
        		temp[i + 1] = item;
        	} 
        	
        	 mini.get("queryBgiBrand").setData(temp);
        	 mini.get("queryBgiBrand").setValue(GoodsQueryHandler.bgbComboxData.bgbId);
        },
        error: function (jqXHR, textStatus, errorThrown) {
        	MiniuiTools.miniError("系统提示",jqXHR.responseText);
        }
    });
}

/**
 * 加载供货商combobox
 */
GoodsQueryHandler.getBgsCombobox = function(){
	$.ajax({
        url: __root + "/getBgsCombobox.do",
        type: "POST",
        cache: false,
        dataType: 'json',
        success: function (text) {
        	var temp = [GoodsQueryHandler.bgsComboxData];
        	for(var i = 0; i < text.length; i++){
        		var item = {bsiId: text[i].bsiId, bsiName: text[i].bsiName};
        		temp[i + 1] = item;
        	} 
        	 mini.get("queryBgiSupplier").setData(temp);
        	 mini.get("queryBgiSupplier").setValue(GoodsQueryHandler.bgsComboxData.bsiId);
        },
        error: function (jqXHR, textStatus, errorThrown) {
            MiniuiTools.miniError("系统提示",jqXHR.responseText);
        }
    });
}
